export class CompositeData {

    /** 材料道具 id  id1::id2::id3......*/
    public materialPropDatas:string;
    /** 最终会合成的道具*/
    public compositeData:number;

    constructor(obj: string){
        this.materialPropDatas = obj['materialPropDatas'];
        this.compositeData = obj['compositeData'];
    }

     /** 判断是否满足合成*/
    public  IsCanComposite(materialPropList:Array<number>):boolean
    {
         let materialIdStrs = this.materialPropDatas.split("::");
         let materialIdInt = new Array<number>();

         for (let index = 0; index < materialIdStrs.length; index++) {
            materialIdInt[index] = parseInt(materialIdStrs[index]);
         }
         let length = materialIdStrs.length;
         /** 数量不对等 直接返回*/
         if (length != materialPropList.length)
         {
             return false;
         }
         else
         {
             /** 判断具体的材料*/
             /** 需要的道具 id*/

             for (let i = 0; i < length; i++)
             {
                 let id = materialIdInt[i];
                 /** 不是提供的材料 直接返回false*/
                 if (materialPropList.indexOf(id) == -1)
                 {
                     return false;
                 }
             }
             return true;
         }
     }
}